package com.test.service;


import com.test.dao.CompOperatDao;
import com.test.dao.StuOperatDao;

import com.test.entity.CompAllInfoDto;
import com.test.entity.StuAllInfoDto;
import com.test.entity.TimeTableDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@Service
public class CompOperatService {
    @Autowired
    private CompOperatDao compOperatDao;


    public List<StuAllInfoDto>  selectMyAttentStu(String acount){

        List<StuAllInfoDto>  list = null;


        String compName = compOperatDao.selectCompNameByAcount(acount);
        if(compName!=null&&!"".equals(compName)){
            list = compOperatDao.selectMyAttentStu(compName);
        }
        return  list;
    }


    public int compAttentStu(String acount,String stu_name){

        String compName = compOperatDao.selectCompNameByAcount(acount);
        List<Map<String,Object>> list = compOperatDao.selectAttentByacount(acount);
        int count = 0;
        for(int i = 0;i<list.size();i++){
            String compname = list.get(i).get("comp_name").toString();
            if(compname.equals(stu_name)){
                count++;
            }

        }
        if(compName!=null&&!"".equals(compName)){
            compName = compName;
        }else{
            compName = null;
        }
        int result = 0;
        if(count<1){
            result = compOperatDao.compAttentStu(acount,compName,stu_name);
        }
        return  result;
    }


    public List<StuAllInfoDto> selectCompAttentStu(String comp_acount){
        List<StuAllInfoDto> allstulist = compOperatDao.selectCompAttentStu(comp_acount);
        return  allstulist;
    }

    public List<StuAllInfoDto> selectStuOnline(String comp_acount){
        List<StuAllInfoDto> allstulist = compOperatDao.selectStuOnline(comp_acount);
        return  allstulist;
    }

    public int  agreeOnlineApplication(String acount,String stu_acount,String wangshenjob){
        int  result = compOperatDao.agreeOnlineApplication( acount,stu_acount,wangshenjob);
        return  result;
    }

    public int  compyuyuebishi(String acount,String stu_acount,String wangshenjob){
        int  result = compOperatDao.compyuyuebishi( acount,stu_acount,wangshenjob);
        return  result;
    }

    public int  compyuyuemianshi(String acount,String stu_acount,String wangshenjob){
        int  result = compOperatDao.compyuyuemianshi( acount,stu_acount,wangshenjob);
        return  result;
    }


    public int  sendOffer(String acount,String stu_acount,String wangshenjob){
        int  result = compOperatDao.sendOffer( acount,stu_acount,wangshenjob);
        return  result;
    }

    public int  disOnlineApplication(String acount,String stu_acount,String wangshenjob){
        int  result = compOperatDao.disOnlineApplication( acount,stu_acount,wangshenjob);
        return  result;
    }

    public int  rebackOnlineApplication(String acount,String stu_acount,String wangshenjob){
        int  result = compOperatDao.rebackOnlineApplication( acount,stu_acount,wangshenjob);
        return  result;
    }
}
